home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / ant_nec / nec_in_c.tz / nec_in_c / NEC2 / rsfe.c < prev    next >
C/C++ Source or Header  |  1992-02-13  |  1KB  |  71 lines

  1. /* read sequential formatted external */
  2. #include "f2c.h"
  3. #include "fio.h"
  4. #include "fmt.h"
  5. extern int x_getc(),rd_ed(),rd_ned();
  6. extern int x_endp(),x_rev(),xrd_SL();
  7. integer s_rsfe(a) cilist *a; /* start */
  8. {    int n;
  9.     if(!init) f_init();
  10.     if(n=c_sfe(a)) return(n);
  11.     reading=1;
  12.     sequential=1;
  13.     formatted=1;
  14.     external=1;
  15.     elist=a;
  16.     cursor=recpos=0;
  17.     scale=0;
  18.     fmtbuf=a->cifmt;
  19.     curunit= &units[a->ciunit];
  20.     cf=curunit->ufd;
  21.     if(pars_f(fmtbuf)<0) err(a->cierr,100,"startio");
  22.     getn= x_getc;
  23.     doed= rd_ed;
  24.     doned= rd_ned;
  25.     fmt_bg();
  26.     doend=x_endp;
  27.     donewrec=xrd_SL;
  28.     dorevert=x_rev;
  29.     cblank=curunit->ublnk;
  30.     cplus=0;
  31.     if(curunit->uwrt && nowreading(curunit))
  32.         err(a->cierr,errno,"read start");
  33.     return(0);
  34. }
  35. xrd_SL()
  36. {    int ch;
  37.     if(!curunit->uend)
  38.         while((ch=getc(cf))!='\n' && ch!=EOF);
  39.     cursor=recpos=0;
  40.     return(1);
  41. }
  42. x_getc()
  43. {    int ch;
  44.     if(curunit->uend) return(EOF);
  45.     ch = getc(cf);
  46.     if(ch!=EOF && ch!='\n')
  47.     {    recpos++;
  48.         return(ch);
  49.     }
  50.     if(ch=='\n')
  51.     {    (void) ungetc(ch,cf);
  52.         return(ch);
  53.     }
  54.     if(curunit->uend || feof(cf))
  55.     {    errno=0;
  56.         curunit->uend=1;
  57.         return(-1);
  58.     }
  59.     return(-1);
  60. }
  61. x_endp()
  62. {
  63.     (void) xrd_SL();
  64.     return(0);
  65. }
  66. x_rev()
  67. {
  68.     (void) xrd_SL();
  69.     return(0);
  70. }
  71.